<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<%@ include file="/common/meta.jsp"%>

<script language="Javascript"  src="${ ctx}/scripts/htmlbox/htmlbox.colors.js" type="text/javascript"></script>
<script language="Javascript"  src="${ ctx}/scripts/htmlbox/htmlbox.styles.js" type="text/javascript"></script>
<script language="Javascript"  src="${ ctx}/scripts/htmlbox/htmlbox.syntax.js" type="text/javascript"></script>
<script language="Javascript"  src="${ ctx}/scripts/htmlbox/xhtml.js"  type="text/javascript"></script>
<script language="Javascript"  src="${ ctx}/scripts/htmlbox/htmlbox.min.js" type="text/javascript"></script>
<script language="Javascript"  src="${ ctx}/scripts/htmlbox/htmlbox.undoredomanager.js"  type="text/javascript"></script>

<style type="text/css">
.page-content {
	width: 1200px;
	margin: 0 auto;
	border-radius: 10px;
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px;
	position: relative;
	padding-top: 15px;
}

#column-main {
   width: 710px;
   float: left;
   border-left: dotted 0px;
   padding-left: 0px;
   border-left: dotted 0px;
   
   padding-right: 20px;
   -moz-box-shadow: 0 10px 20px #b0b3b6;    /*我们在这里设置阴影，同时设置padding-right使得其偏向于右边，（注：需要设置boreder当然需要设置其宽度为0使其看不见）*/
   -webkit-box-shadow: 0 10px 20px #b0b3b6;
   box-shadow: 0 10px 20px #b0b3b6;
   vertical-align: middle;
}

#column-left {
	margin-right: 24px;
	padding-top: 0px;
	padding-left: 0px;
	padding-bottom: 50px;
	width: 160px;
	float: left;
}

input.button {
	background-color: rgba(47, 167, 226, 0.66);
	border: 1px solid rgb(51, 157, 189);
	color: rgb(250, 250, 252);
	cursor: pointer;
	font-size: 1em;
	height: 23px;
	padding: 2px 5px;
	vertical-align: middle;
	margin-top: 4px;
	margin-right: 10px;
}
</style>


<script language="javascript">
	$(document).ready(
			function() {
				
			  var htmlBox = $("#myHtmlBox").css("height", "300").css("width","700").css("padding","10px 2px").htmlbox(
						{
							toolbars : [
							[ "bold", "italic", "underline", "separator","justify", "left", "center", "right","separator", "link",
							  "unlink", "separator","image", "code", "highlight" ] ],
							skin : "blue"
						});
				
			  // articleFrom 1:音乐   2：视频   3 图片   4 普通文字  
			  function AddHidden(){
	 			    //音乐隐藏域添加信息  {'musicId':{musicId}}
	 			   var musicHidden = $("#data-music-hidden").attr("data-music-hidden");
	 				if((typeof musicHidden)== 'string' && musicHidden.length>0){
	 				   $("#data-music-hidden").attr("data-music-hidden",""); 
	 				   musicHidden = musicHidden.substring(0,musicHidden.length-1);
	 				   $("#articleFrom").attr("value","1"); 
	 				   $("#musicJson").attr("value",musicHidden);
					}
	 			    
	 			   //视频隐藏域添加信息  {'videoId':{videoId}}
	 			   var videoHidden = $("#data-video-hidden").attr("data-video-hidden");
	 				if((typeof videoHidden)== 'string' && videoHidden.length>0){
	 				   $("#data-video-hidden").attr("data-video-hidden",""); 
	 				   videoHidden = videoHidden.substring(0,videoHidden.length-1);
	 				   $("#articleFrom").attr("value","2"); 
	 				   $("#videoJson").attr("value",videoHidden);
					}
	 				
	 				
	 				 //图片隐藏域添加信息  {'fileId':{fileId}}
	 				var pictureHidden = $("#data-file-hidden").attr("data-file-hidden");
	 				if((typeof pictureHidden)== 'string' && pictureHidden.length>0){
	 				   $("#data-file-hidden").attr("data-file-hidden",""); 
	 				   pictureHidden = pictureHidden.substring(0,pictureHidden.length-1);
	 				   $("#articleFrom").attr("value","3"); 
	 				   $("#pictureJson").attr("value",pictureHidden);
					}
	 			    
				
			  }

			  //保存为草稿	
			  $("#saveDraft").click(function(){
				  if($("#required").val()!=null&&$("#required").val()!=""&&$("#select_required").find('option:selected').text()!=null&&$("#select_required").find('option:selected').text()!="==选择博客==")
				  {
				  $("#articleFrom").attr("value","4");   //默认为普通文字
				  AddHidden();
				  $("#draft").attr("value",0);
				  $("#form1")[0].submit();
				  }else{
					  alert("文章标题和所属博客为必填选项");
				  }
			  });
				
			   //直接保存博文
			   $("#saveArticle").click(function() {
				   if($("#required").val()!=null&&$("#required").val()!=""&&$("#select_required").find('option:selected').text()!=null&&$("#select_required").find('option:selected').text()!="==选择博客==")
				  {
				   $("#articleFrom").attr("value","4");   //默认为普通文字
		        AddHidden();
		        $("#draft").attr("value",1);
			    $("#form1")[0].submit();
			   }else{
					  alert("文章标题和所属博客为必填选项");
				  }
 			});

	});
</script>

<title>新建文章</title>
</head>
<body>
<body id="page-home">
	<%@ include file="/common/header.jsp"%>
	<div class='page-content'>

		<div id='column-left'><%@ include file="/common/left.jsp"%></div>

		<div id="column-main">
			<form id="form1" style="padding: 10px 10px;" action="${ctx }/blog/blog.action?method:saveArticle"  method="post">
			
			<div style="margin-bottom: 3px;">
			<strong>文章标题</strong><span style="color: red; margin-left: 5px; font-weight: bold">*</span>
			<input id="required"     maxlength="80" name="article.title" size="45"
			       style="width: 350px; border: 1px solid grey; height: 20px;" type="text" value="${article.title}" /> 
			</div>
			
			<div  style="margin-bottom: 10px;">
			<c:if test="${not empty param.blogId}">
			<input type="hidden" name="article.blogId" value="${param.blogId }"/>
			</c:if>
			<c:if test="${empty param.blogId }">
			  <strong>所属博客</strong><span style="color: red; margin-left: 5px; font-weight: bold">*</span> 
			  <nativeSql:sqlQueryForList sql="select * from t_blog where (f_manager_id=${me.id} or f_type='public') 
			  				order by f_manager_name desc" id="blogs"/>
			  <s:select name="article.blogId" list="#attr.blogs" listKey="f_id" listValue="f_blog_name" theme="simple"  style="height:22px;" id="select_required"
			 headerKey="" headerValue="==选择博客=="/>&nbsp;&nbsp; 
			</c:if>
		  	<strong>博文标签&nbsp;&nbsp;</strong><input type="text" id="tag_tagName" title="请输入标签"
									name="article.tags" value="${article.tags}"
									style="border: 1px solid grey; width: 280px; height: 20px;" />&nbsp;&nbsp;(以逗号,空格区分)

			 </div>
			
			<input id="articleFrom" type="hidden" name="articleFrom" value="-1" ><!-- 1:音乐   2：视频   3 图片   4 普通文字-->
			<input id="musicJson"   type="hidden" name="musicJson"   value="-1" >
			<input id="videoJson"   type="hidden" name="videoJson"   value="-1" >
			<input id="pictureJson" type="hidden" name="pictureJson" value="-1" >
			<input id="draft"  type="hidden" name="article.draft"  value="-1" >
			 
		    <!-- 文本编辑框 -->
			<textarea id='myHtmlBox' name="article.content"></textarea>
			<input class="button"  style="float:right;" type="button" value="保存草稿" id="saveDraft"></input>
			<input class="button"  style="float:right;" type="button" value="发表博文" id="saveArticle"></input>
			<br>
			<br>
			<br> 
		
		</form>	
		
		<c:if test="${fn:contains(param.type,'text')}"> </c:if>	
		
        <c:if test="${fn:contains(param.type,'picture')}"><%@ include file="/blog/picturePart.jsp" %> </c:if>		
        
		<c:if test="${fn:contains(param.type,'music')}"> <%@ include file="/blog/musicPart.jsp" %> </c:if>	
		
		<c:if test="${fn:contains(param.type,'video')}"> <%@ include file="/blog/videoPart.jsp" %> </c:if>		
			
		</div>
	</div>

	<div style="clear: both;"></div>
	<%@ include file="/common/footer.jsp"%>

</body>
</html>